package com.example.demo.controller.exception;

import com.example.demo.controller.resp.Response;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionAdvice {

    @ExceptionHandler(value = BizException.class)
    public Response<?> bizException(BizException exception){
        return Response.fail(exception.getLocalizedMessage());
    }

    @ExceptionHandler(value = Exception.class)
    public Response<?> unknownException(Exception exception){
        return Response.fail("服务器繁忙，请稍后再试试");
    }
}
